<?php
require_once "jssdk.php";
$jssdk = new JSSDK("wx4f81c66e3afd08c7", "0ec10ed2b46b5404e27417ec10d8c424");
$accessToken = $jssdk->getAccessToken();
$serverId = "4wRUWOFu-QeSjA8QDjVQgVJ7SaBjCgzsdis7iy6gu5gz-MDpJUC9yosLu_Fdwlcx";
 
// 要存在你服务器哪个位置？
$targetName = '/home/wwwroot/default/tmp/2019102201.jpg';
$curl = curl_init();
$url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=".$accessToken."&media_id=".$serverId;
var_dump($url);

$filebody = file_get_contents($url); //通过接口获取图片流
$filename = uniqid() . '.jpg'; //定义图片名字及格式
$path = "./weixin/".$filename;  //文件夹必须先存在，注意一般是主入口下文件夹
file_put_contents($path,$filebody); 
?>
